package com.uzai.console.service.feign.impl;

import com.alibaba.fastjson.JSONObject;
import com.uzai.common.result.ResponseCode;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.feign.turnlink.*;
import com.uzai.console.service.feign.UzaiTurnlinkFeignService;
import com.uzai.console.vo.feign.turnlink.SimpleTurnlinkVo;
import com.uzai.console.vo.feign.turnlink.TbPartnerurlAnalysisVo;
import com.uzai.console.vo.feign.turnlink.TbPwdAnalysisVo;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @Auther: jianghan
 * @Date: 2021/11/24 16:24
 * @Description:
 */
@Component
public class UzaiTurnlinkFeignFallbackFactory implements FallbackFactory<UzaiTurnlinkFeignService> {

    private static Logger logger = LoggerFactory.getLogger(UzaiTurnlinkFeignFallbackFactory.class);

    @Override
    public UzaiTurnlinkFeignService create(Throwable throwable) {

        logger.error("--转链调用微服务失败，err={}", throwable);

        return new UzaiTurnlinkFeignService() {
            @Override
            public UzaiRespVo<SimpleTurnlinkVo> tbTurnlinkSimple(SimpleTurnLinkDto simpleTurnLinkDtoDto) {
                UzaiRespVo<SimpleTurnlinkVo> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<SimpleTurnlinkVo> tbActivityTurnlink(SimpleTurnLinkDto simpleTurnLinkDtoDto) {
                return UzaiRespVo.fail("淘宝活动转链失败");
            }

            @Override
            public UzaiRespVo<SimpleTurnlinkVo> jdTurnlinkSimple(SimpleTurnLinkDto simpleTurnLinkDtoDto) {
                UzaiRespVo<SimpleTurnlinkVo> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<SimpleTurnlinkVo> pddTurnlinkSimple(SimpleTurnLinkDto simpleTurnLinkDtoDto) {
                UzaiRespVo<SimpleTurnlinkVo> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<SimpleTurnlinkVo> vphTurnlinkSimple(SimpleTurnLinkDto simpleTurnLinkDtoDto) {
                UzaiRespVo<SimpleTurnlinkVo> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<SimpleTurnlinkVo> dyTurnlinkSimple(SimpleTurnLinkDto simpleTurnLinkDtoDto){
                UzaiRespVo<SimpleTurnlinkVo> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<SimpleTurnlinkVo> ksTurnlinkSimple(SimpleTurnLinkDto simpleTurnLinkDtoDto) {
                UzaiRespVo<SimpleTurnlinkVo> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("快手简版转链调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<TbPwdAnalysisVo> tbPwdAnalysis(TbPwdAnalysisDto tbPwdAnalysisDto) {
                UzaiRespVo<TbPwdAnalysisVo> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<TbPartnerurlAnalysisVo> tbPartnerurlAnalysis(TbPartnerurlAnalysisDto tbPartnerurlAnalysisDto) {
                UzaiRespVo<TbPartnerurlAnalysisVo> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<String> generateShortUrl(@RequestBody GenerateShortUrlDto generateShortUrlDto) {
                UzaiRespVo<String> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<String> pddCheckAuthority(PddTokenRecordDto pddTokenRecordDto) {
                UzaiRespVo<String> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<String> pddGenRpurl(PddTokenRecordDto pddTokenRecordDto) {
                UzaiRespVo<String> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<JSONObject> tbItemInfo(String itemId) {
                UzaiRespVo<JSONObject> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<JSONObject> getTbPrivilege(TbPrivilegeDto tbPrivilegeDto) {
                UzaiRespVo<JSONObject> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }



        };
    }

}
